<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8" />
		<meta http-equiv="Expires" content="0">
		<meta http-equiv="Pragma" content="no-cache">
		<meta http-equiv="Cache-control" content="no-cache">
		<meta http-equiv="Cache" content="no-cache">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
		<title>博客定时任务列表</title>
		<script type="text/javascript" src="../../commonFragment/header.js?v=1"></script>
		<script type="text/javascript" src="../../commonFragment/nojs.header.js"></script>
		<script>
			// 立即执行
			// 暂停 删除 运行
			function defaultOperateTask(value, row, index, field) {
				let html = defaultOperate(value, row, index, field);
				html += buildBtn(row.id, row.status);
				return html;
			}
			
			
			function buildBtn(id, status){
				let url = "/blog/taskJob/operate";
				let data = {
					1:{
						confirm:"确认启动定时器吗?",
						title:"启动",
						status:1,
						icon:'fa-play',
						btnClass:'btn-info'
					},
					2:{
						confirm:"确认暂停定时器吗?",
						title:"暂停",
						status:2,
						icon:'fa-pause',
						btnClass:'btn-warning'
					},
					0:{
						confirm:"确认移除定时器吗?",
						title:"移除",
						status:0,
						icon:'fa-remove',
						btnClass:'btn-danger'
					},
					
				};
				var html = '';
				for(var k in data){
					if(status == k){
						continue;
					}
					var v = data[k];
					html +=
					'<a data-url="' + url +'" class="action-post btn btn-xs '+ v.btnClass+'" data-confirm="'+v.confirm+'" title="'+v.title+'" data-toggle="tooltip" data-after="after">'
					+ '<i class="fa '+v.icon+'"></i>'
					+ '<i class="action-param" data-key="id" data-value="' + id +'" ></i>'
					+ '<i class="action-param" data-key="status" data-value="'+v.status+'" ></i>'
					+'</a>' ;
				}
				//立即执行
				html +=
				'<a data-url="/blog/taskJob/runJob" class="action-post btn btn-xs btn-success" data-after="after" data-confirm="确定立刻运行一次吗" title="立刻运行" data-toggle="tooltip">'
				+ '<i class="fa fa-fast-forward"></i>'
				+ '<i class="action-param" data-key="id" data-value="' + id +'" ></i>'
				+'</a>' ;
				return html;
				
			}
			
			function after(){
				$("#table").bootstrapTable('refresh');
			}
				
		</script>
	</head>
	<body>
		<div class="container-fluid p-t-15">
			<div class="row">
				<div class="col-lg-12">
					<div class="card">
						<div class="card-body">
							<form id="toolbar" class="form-inline">
								<!-- 操作按钮 -->
								<div class="form-group btn-group btn-group-sm ">
									<button type="button" class="btn  btn-success add-multitab" data-id="add-user-form" data-url="module/blog/task_job_form.html"
									 data-title="新增博客定时任务">
										<i class="glyphicon glyphicon-plus"></i> 添加
									</button>

									<button class="btn btn-danger bootable-action-post" type="button" data-table="#table" data-href="/blog/taskJob/batchDelete"
									 data-confirm="确认删除吗">
										<span class="glyphicon glyphicon-trash"></span> 删除
									</button>
								</div>
								<!-- 查询条件 -->
								<div class="form-group">
									<label class="sr-only" for="id"></label>
									<input type="text" class="form-control input-sm" id="id" name="id" placeholder="请输入" autocomplete="off">
								</div>

								<div class="form-group">
									<label class="sr-only" for="engine">是否启用</label>
									<select class="form-control input-sm" id="enable" name="enable" data-value="">
										<option value="">--请选择是否启用--</option>
										<option value="0">否</option>
										<option value="1">是</option>
									</select>
								</div>

								<div class="form-group ">
									<button type="button" class="btn btn-primary btn-sm query">
										<i class="glyphicon glyphicon-search"></i> 查询
									</button>
									<button type="button" class="btn btn-info btn-sm reset">
										<i class="glyphicon glyphicon-refresh"></i> 重置
									</button>
								</div>

							</form>
							<table id="table" class="table table-bordered table-hover table-striped bootstrapTable" data-list-url="/blog/taskJob/list"
							 data-form-url="module/blog/task_job_form.html" data-del-url="/blog/taskJob/delete" data-toolbar="#toolbar">
								<thead>
									<tr>
										<th data-checkbox="true"></th>
										<th data-field="code" data-sortable="true">code</th>
										<th data-field="name" data-sortable="true">名称</th>
										<th data-field="group" data-sortable="true">组</th>
										<th data-field="clazz" data-sortable="true">job类</th>
										<th data-field="cron" data-sortable="true">cron表达式</th>
										<th data-field="status" data-sortable="true">状态</th>
										<th data-field="enable" data-formatter="showEnbale" data-sortable="true">启用</th>
										<th data-field="createTime" data-sortable="true">创建时间</th>
										<th data-field="operate" data-formatter="defaultOperateTask" data-events="defaultOperateEvent">操作</th>
									</tr>
								</thead>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>

</html>
